﻿using System;
using System.Collections.Generic;
using System.Text;
using ActiproSoftware.SyntaxEditor;

namespace WindowsUserControl.Codes
{
    /// <summary>
    /// Represents a number expression.
    /// </summary>
    public class NumberExpression : Expression
    {

        private System.Int32 number;

        /// <summary>
        /// Gets the minimum context ID that should be used in your code for AST nodes inheriting this class.
        /// </summary>
        /// <remarks>
        /// Base all your context ID constants off of this value.
        /// </remarks>
        protected const byte NumberExpressionContextIDBase = Expression.ExpressionContextIDBase;

        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // OBJECT
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <c>NumberExpression</c> class.
        /// </summary>
        /// <param name="number">The number.</param>
        /// <param name="textRange">The <see cref="TextRange"/> of the AST node.</param>
        public NumberExpression(int number, TextRange textRange)
            : this(textRange)
        {
            // Initialize parameters
            this.number = number;
        }

        /// <summary>
        /// Initializes a new instance of the <c>NumberExpression</c> class. 
        /// </summary>
        public NumberExpression() { }

        /// <summary>
        /// Initializes a new instance of the <c>NumberExpression</c> class. 
        /// </summary>
        /// <param name="textRange">The <see cref="TextRange"/> of the AST node.</param>
        public NumberExpression(TextRange textRange) : base(textRange) { }

        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Accepts the specified visitor for visiting this node.
        /// </summary>
        /// <param name="visitor">The visitor to accept.</param>
        /// <remarks>This method is part of the visitor design pattern implementation.</remarks>
        protected override void AcceptCore(AstVisitor visitor)
        {
            if (visitor.OnVisiting(this))
            {
                // Visit children
                if (this.ChildNodeCount > 0)
                    this.AcceptChildren(visitor, this.ChildNodes);
            }
            visitor.OnVisited(this);
        }

        /// <summary>
        /// Gets the <see cref="SimpleNodeType"/> that identifies the type of node.
        /// </summary>
        /// <value>The <see cref="SimpleNodeType"/> that identifies the type of node.</value>
        public override SimpleNodeType NodeType
        {
            get
            {
                return SimpleNodeType.NumberExpression;
            }
        }

        /// <summary>
        /// Gets or sets the number.
        /// </summary>
        /// <value>The number.</value>
        public System.Int32 Number
        {
            get
            {
                return number;
            }
            set
            {
                number = value;
            }
        }

        /// <summary>
        /// Gets text representing the node that can be used for display, such as in a document outline.
        /// </summary>
        /// <value>Text representing the node that can be used for display, such as in a document outline.</value>
        public override string DisplayText
        {
            get
            {
                return "Number " + this.Number;
            }
        }

    }

}
